package com.ari.actions;

import java.util.Arrays;
import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.devicemantra.coordinate.dao.HibernateUtil;

public class FunctionalTestingAction {

	static final Logger logger = Logger
			.getLogger(FunctionalTestingAction.class);
	private static List<String> commandTypeList = null;
	static {
		commandTypeList = Arrays.asList("Hello", "Login", "Logout",
				"Domain Create", "Contact Create");
	}

	public FunctionalTestingAction() {
	}

	public String execute() {
		logger.info(" *********    ** **********" + this);
		Transaction transaction = null;
		try {
			final Session session = HibernateUtil.getSession();
			transaction = session.beginTransaction();
			// session.save(settings);
			transaction.commit();
		} catch (final HibernateException e) {
			System.out.println("Rolling back");
			transaction.rollback();
			e.printStackTrace();
		}
		return "success";
	}

	public void validate() {
	}

	@Override
	public String toString() {
		final StringBuilder builder = new StringBuilder();
		return builder.toString();

	}

	public List<String> getCommandTypeList() {
		return commandTypeList;
	}
}
